﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Luna.NHibernate;
using XWord.Fundamental.Data.Repositories;
using uNhAddIns.Adapters;
using XWord.Fundamental.Domain.Model;

namespace XWord.Fundamental.Domain.Impl
{
    [PersistenceConversational(MethodsIncludeMode = MethodsIncludeMode.Implicit)]
    public class CategoryModel : ICategoryModel
    {
        private readonly ICategoryRepository _categoryRepository;

        public CategoryModel(ICategoryRepository categoryRepository)
        {
            _categoryRepository = categoryRepository;
        }

        public IList<Category> GetCategoryList()
        {
            return _categoryRepository.GetAll();
        }

        [PersistenceConversation(ConversationEndMode = EndMode.CommitAndContinue)]
        public void SaveCategory(Category cat)
        {
            _categoryRepository.MakePersistent(cat);
        }

        [PersistenceConversation(ConversationEndMode = EndMode.CommitAndContinue)]
        public void DeleteCategory(Category cat)
        {
            _categoryRepository.MakeTransient(cat);
        }

        public Category GetCategoryById(object Id)
        {
            return _categoryRepository.Get(Id);
        }


    }


}
